<template>
  <view class="content">
    <view class="swiper_box" >
	
	
	<swiper style="width: 100%;"  :circular="true" :indicator-dots="true"
	indicator-active-color="#C00000"
	:autoplay="true" :interval="3000" :duration="1000" >
		<swiper-item class="swiper_item" v-for="(item,index) in swrperData.data" :key="index" >
			
      <image class="sw_image" :src="item.src"></image>

				<!-- <navigator :url= "`/subpkg/goodes_details/goodes_details?goods_id=${item.goods_id}`">
					 
				</navigator> -->
				
			
		</swiper-item>
	
	</swiper> 
	
</view>

<uni-card v-for="(item,index) in indexData.subject"  
:title="item.title" :sub-title="item.subject" extra=""
>
	{{ item.introduce }}
  <view style="margin-top: 10px;">
  <p @click="tiao(item.id)" style=" border-radius: 4px; background-color: #029d94;height: 80rpx; line-height: 80rpx;
  
  display: flex;justify-content: center;padding: 0 10rpx;color: aliceblue;">

    
    <span   style="font-size: 16px;">开始考试</span>
  </p>

</view>

</uni-card>
  </view>
</template>

<script setup lang="ts">
import {getKemu,getKimg} from '../../api/login'
import { ref , reactive,computed} from 'vue'

import { useCounterStore } from '../../stores/counter'
const counter = useCounterStore()
// 一个计算属性 ref
const token = computed(() => {
  return counter.token
})
interface img{
  src:string,
  ref:string
}
interface swrperData{
  data:img[]
}
const  swrperData:swrperData=reactive({
  data:[],

}) 
const imgdaAa=async()=>{
const {data} = await getKimg()
console.log(data);
swrperData.data=data.data

}
imgdaAa()
// 获取科目
const indexData:any=reactive({
  subject:null
})
const getData =  async ()=>{

  const {data} = await getKemu();
  
  indexData.subject=data.data
}
getData()
const tiao=(id:any)=>{
if(token.value){
  uni.navigateTo({
  url: `/subpkg/dati/index`,
  success: function(res:any) {
    // 通过eventChannel向被打开页面传送数据
    res.eventChannel.emit('acceptDataFromOpenerPage', 
    
    { id
     })
  }
 
})
}else{
  uni.showToast({
	title: '请先登录！',
  icon:"error",
	duration: 1000
});

setTimeout(()=>{
  uni.switchTab(
      {
	url: '../../pages/my/index'
}
    )
},500)
}
  

}
</script>

<style lang="scss" scoped>
.swiper_item{height: 150px;
.sw_image{
	width: 100%;
	height: 150px;
}
}

.fenye1{
	
	padding: 0 5px;
	display: flex;
	justify-content: space-between;
	
		
	.fenyue2{
		display: flex;
		
		flex-direction:column;
		margin-top: 20px;
		
		.fenyue2_img{
		width: 128rpx;
		    height: 140rpx;
		}
	}
}
.floor-title {
  height: 60rpx;
  width: 100%;
  display: flex;
}
.right-img-box {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}

.floor-img-box {
  display: flex;
  padding-left: 10rpx;
}
 .serwch{
	 position: sticky;
	 
	 top: 0;
	 z-index: 9999;
 }
.baox{
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  width: 100%;
  
  view{
   
    width: 49%;
    margin-top: 10rpx;
  height: 250rpx;
  background-color: aqua;
  }}
</style>
